import { IPSRawItemBase } from '../ipsraw-item-base';
import { IPSRawItemContainer } from '../ipsraw-item-container';
import { IPSDEFormRawItem } from './ipsdeform-raw-item';
import { PSDEFormDetailImpl } from './psdeform-detail-impl';

export class PSDEFormRawItemImpl extends PSDEFormDetailImpl implements IPSDEFormRawItem, IPSRawItemContainer {
  get contentType(): 'RAW' | 'HTML' | 'IMAGE' | 'MARKDOWN' | 'VIDEO' | 'PLACEHOLDER' | 'DIVIDER' | 'INFO' | 'WARNING' | 'ERROR' | 'USER' | 'USER2' {
    return this.M.contentType;
  }

  get cssStyle(): string {
    return this.M.cssStyle;
  }

  get dynaClass(): string {
    return this.M.dynaClass;
  }

  get htmlContent(): string {
    return this.M.htmlContent;
  }

  protected psrawitem: IPSRawItemBase | null = null;

  getPSRawItem(): IPSRawItemBase | null {
    if (this.psrawitem != null) return this.psrawitem;
    const value = this.M.getPSRawItem;
    if (value == null) {
      return null;
    }
    this.psrawitem = this.getPSModel4('control.IPSRawItemBase', value, 'getPSRawItem') as IPSRawItemBase;
    return this.psrawitem;
  }

  get psRawItem(): IPSRawItemBase | null {
    return this.getPSRawItem();
  }

  getPSRawItemMust(): IPSRawItemBase {
    const value = this.getPSRawItem();
    if (value == null) {
      throw new Error('未指定直接内容对象');
    }
    return value;
  }

  get rawContent(): string {
    return this.M.rawContent;
  }

  get rawItemHeight(): number {
    return this.M.rawItemHeight != null ? this.M.rawItemHeight : 0.0;
  }

  get rawItemWidth(): number {
    return this.M.rawItemWidth != null ? this.M.rawItemWidth : 0.0;
  }

  get cls(): string {
    return 'PSDEFormRawItemImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.IPSRawItem' || cls == 'control.IPSRawItemContainer' || cls == 'control.form.IPSDEFormRawItem') return true;
    return super.instanceof(cls);
  }
}
